package com.franklin.java.api.ui.jpanel.line;

import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBPanel;

import java.awt.*;

/**
 * 直线
 * @author Franklin
 * @since 2021/9/3 10:24
 */
public class LinePanel extends JBPanel<LinePanel> {

    /**
     * 颜色
     */
    protected Color color;

    /**
     * 起点
     */
    protected Point startPoint;

    /**
     * 终点
     */
    protected Point endPoint;

    public LinePanel(Point startPoint, Point endPoint) {
        this(JBColor.pink,startPoint,endPoint);
    }

    public LinePanel(Color color, Point startPoint, Point endPoint) {
        this.color = color;
        this.startPoint = startPoint;
        this.endPoint = endPoint;
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);

        g.setColor(color);
        g.drawLine(startPoint.x,startPoint.y,endPoint.x,endPoint.y);
    }
}
